//
//  Model.m
//  阅色(首页)
//
//  Created by 殷殷明静 on 16/9/9.
//  Copyright © 2016年 MJ.Y. All rights reserved.
//

#import "Model.h"

@implementation Model
- (void)setValue:(id)value forKey:(NSString *)key {
    // 一定要继承父类
    [super setValue:value forKey:key];
    if ([key isEqualToString:@"data"]) {
        NSMutableArray <DataModel *> *arr = [NSMutableArray array];
        for (NSDictionary *dic in value) {
            DataModel *data = [DataModel modelWithDic:dic];
            [arr addObject:data];
        }
        
        _data = arr;
        
    }
}
- (instancetype)initWithCoder:(NSCoder *)aDecoder {
    self = [super init];
    if (self) {
        _requestId = [aDecoder decodeObjectForKey:@"_requestId"];
        _data = [aDecoder decodeObjectForKey:@"_data"];
    }
    return self;
}
- (void)encodeWithCoder:(NSCoder *)aCoder {
    [aCoder encodeObject:_requestId forKey:@"_requestId"];
    [aCoder encodeObject:_data forKey:@"_data"];
}
@end
